package com.usfuture.chart.ins
{
	import com.usfuture.chart.IChart;
	import com.usfuture.chart.util.GraphicsUtil;
	import com.usfuture.event.DataEvent;
	import com.usfuture.ins.entity.Ins;
	import com.usfuture.insInfo.entity.InsInfo;
	import com.usfuture.util.NumberFormat;
	
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.text.StyleSheet;
	import flash.text.TextField;

	public class InsChart extends EventDispatcher implements IChart
	{

		private var _canvas:Sprite;
		private var _data:Array;
		private var _insInfo:InsInfo;
		private var _leftWidthX:Number=60; //走势图距画布左边的距离
		private var _rightWidthX:Number=60; //走势图距画布右边的距离
		private var _topWidthY:Number=5; //走势图距画布上边的距离
		private var _buttomWidthY:Number=20; //走势图距画布下边的距离
		private var _insHeightRate:Number=0.6666666; //趋势图高度所占的比例
		private var _insStartPoint:Point; //走势图的起点位置
		private var _volStartPoint:Point; //走势图的起点位置
		private var _insHeight:Number; //走势图的高度
		private var _volHeight:Number; //成交量的高度
		private var _insWidth:Number; //走势图的宽度
		private var _volWidth:Number; //成交量的宽度
		private var _highPrice:Number; //最高价
		private var _lowPrice:Number; //最低价
		private var _highVol:Number; //最高量

		private var _divideHeight:int=12; //高度12等分
		private var _maxSpread:Number; //与昨收差价最大的差值
		//private var _times:Array=["08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00"];
		private var _leftPriceLabels:Array;
		private var _rightPercentLabels:Array;
		private var _timeLabels:Array;
		private var _amountLabels:Array;
		private var _cursor:Shape;

		//////////////////////////////////////////////////////////////////////////////////////////////
		//
		//根据传进来的开始时间和结束时间求得等分X轴的算法
		//                width
		//  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		//  │——│—————│—————│—————│—————│———│
		//  │  │     │     │     │     │   │
		//  │  │     │     │     │     │   │
		//  │__│_____│_____│_____│_____│___│
		//  r1*x  x     x     x    x    r2*x
		//     ~~~~~~~~~~~~~~~~~~~~~~~~~
		//              n(个)
		// 公式：r1*x+n*x+r2*x = width 
		//       x:一个小时宽度
		//       r1、r2:一个小时所占比率
		/////////////////////////////////////////////////////////////////////////////////////////////
		private var _divideXNum:int=9; //宽度13等分
		private var _divideXWidth:Number;
		private var _divideStartXPos:Number;
		private var r1:Number;
		private var r2:Number;

		private var _startTime:Date;
		private var _endTime:Date;
		private var _restTime:Date;
		private var _minuteShow:Boolean=true;
		private var _hourOffset:int;
		private var _restHour:int;//休息的小时  -1代表不休息
		
		private var _insShowLabel:TextField;


		public function InsChart(canvas:Sprite,
								 startTime:String,
								 endTime:String,
								 minuteShow:Boolean=false,
								 hourOffset:int=0,
								 restHour:int=-1
								)
		{
			this._canvas = canvas;
			this._minuteShow = minuteShow;
			this._hourOffset = hourOffset;
			this._restHour = restHour;
			this._canvas.addEventListener(MouseEvent.MOUSE_MOVE,onMovseMove);
			this._canvas.addEventListener(MouseEvent.MOUSE_OUT,onMovseOut);
			//////////////////////////////////////////////////////////////////////////////////////////////
			//
			// 初始化
			//
			/////////////////////////////////////////////////////////////////////////////////////////////
			_insShowLabel = new TextField;
			_insShowLabel.border = true;
			_insShowLabel.borderColor = 0x969696;
			_insShowLabel.multiline = true;
			_insShowLabel.background = true;
			_insShowLabel.backgroundColor = 0xffffff;
			_insShowLabel.width = 100;
			_insShowLabel.height = 65;
			_insShowLabel.visible = false;
			this._canvas.addChild(_insShowLabel);
			//计算高度和宽度
			_insHeightRate=2 / 3;
			_insWidth=_canvas.width - _leftWidthX - _rightWidthX;
			_volWidth=_insWidth;
			_insHeight=(_canvas.height - _topWidthY - _buttomWidthY) * _insHeightRate;
			_volHeight=(_canvas.height - _topWidthY - _buttomWidthY) * (1 - _insHeightRate);

			//计算起始位置
			_insStartPoint=new Point(_leftWidthX, _topWidthY);
			_volStartPoint=new Point(_leftWidthX, _topWidthY + _insHeight);

			//初始化开始时间，上午9：30分，下午13：00分的时间
			_startTime=new Date(1970, 1, 1, startTime.substr(0, 2), startTime.substr(3, 2), 0, 0);
			//如果结束时间比开始小，则表示有跨天
			if(parseInt(endTime.substr(0, 2)) > parseInt(startTime.substr(0, 2))){
				_endTime=new Date(1970, 1, 1, endTime.substr(0, 2), endTime.substr(3, 2), 0, 0);
			}else{
				_endTime=new Date(1970, 1, 2, endTime.substr(0, 2), endTime.substr(3, 2), 0, 0);
			}
			//如果休息小时比开始小，则表示休息时间在第二天
			if(_restHour != -1)
			if(_restHour < parseInt(startTime.substr(0, 2)))
				_restTime=new Date(1970, 1, 2, _restHour, 0, 0, 0);
			else
				_restTime=new Date(1970, 1, 1, _restHour, 0, 0, 0);
			
			r1=(60 - _startTime.getMinutes()) / 60;
			r2=_endTime.getMinutes() / 60;

			var secondHour:Date=new Date(_startTime.time + (60 - _startTime.getMinutes()) * 60 * 1000);
			var lastSecondHour:Date=new Date(_endTime.time - _endTime.getMinutes() * 60 * 1000);
			//如果中间有休息一小时，则减去一小时
			if(_restHour >= 0)
				_divideXNum=(lastSecondHour.time - secondHour.time - 60*60*1000) / 1000 / 60 / 60;
			else
				_divideXNum=(lastSecondHour.time - secondHour.time) / 1000 / 60 / 60;
			
			_divideXWidth=_insWidth / (r1 + _divideXNum + r2);
			_divideStartXPos=_insStartPoint.x + r1 * _divideXWidth;
			if (r1 == 0)
				_divideXNum--;
			if (r2 == 0)
				_divideXNum--;


			////////////////////////////////////////////////////////////////////////////////////////////////
			//
			// 加载label组件
			//
			///////////////////////////////////////////////////////////////////////////////////////////////
			var _insDivideNum:int=_divideHeight * _insHeightRate;
			var _insDivideHeight:Number=_insHeight / _insDivideNum;
			_leftPriceLabels=new Array;
			for (var i:int=0; i < _insDivideNum; i++)
			{
				var leftLabel:TextField=new TextField;
				leftLabel.selectable=false;
				this._canvas.addChild(leftLabel);
				_leftPriceLabels.push(leftLabel);
			}
			_rightPercentLabels=new Array;
			for (var i:int=0; i <= _insDivideNum; i++)
			{
				var rightLabel:TextField=new TextField;
				rightLabel.selectable=false;
				this._canvas.addChild(rightLabel);
				_rightPercentLabels.push(rightLabel);
			}
			_amountLabels=new Array;
			for (var i:int=0; i < _divideHeight - _insDivideNum; i++)
			{
				var amountLabel:TextField=new TextField;
				amountLabel.selectable=false;
				this._canvas.addChild(amountLabel);
				_amountLabels.push(amountLabel);
			}

			_timeLabels=new Array;
			var firstTimeLabel:TextField=new TextField;
			firstTimeLabel.selectable=false;
			firstTimeLabel.text=NumberFormat.preAddZero(_startTime.getHours()) + ':' + NumberFormat.preAddZero(_startTime.getMinutes());
			this._canvas.addChild(firstTimeLabel);
			_timeLabels.push(firstTimeLabel);

			for (var i:int=0; i <= ((_restHour==-1)?(_divideXNum):(_divideXNum+1)); i++)
			{
				//如果当前的小时为休息，则跳过
				if(((secondHour.getHours() + i) % 24) == _restHour) continue;
				var timeLabel:TextField=new TextField;
				timeLabel.selectable=false;
				timeLabel.text=NumberFormat.preAddZero((secondHour.getHours() + i) % 24) + (_minuteShow ? (':' + NumberFormat.preAddZero(secondHour.getMinutes())) : '');
				this._canvas.addChild(timeLabel);
				_timeLabels.push(timeLabel);
			}

			var lastTimeLabel:TextField=new TextField;
			lastTimeLabel.selectable=false;
			lastTimeLabel.text=NumberFormat.preAddZero(_endTime.getHours()) + ':' + NumberFormat.preAddZero(_endTime.getMinutes());
			this._canvas.addChild(lastTimeLabel);
			_timeLabels.push(lastTimeLabel);

			/////////////////////////////////////////////////////////////////////////////////////////////
			//
			// 计算组件所在位置
			//
			/////////////////////////////////////////////////////////////////////////////////////////////
			measure();

			/////////////////////////////////////////////////////////////////////////////////////////////
			//
			// 添加鼠标事件 
			//
			/////////////////////////////////////////////////////////////////////////////////////////////
			_cursor=new Shape;
			this._canvas.addChild(_cursor);
			this.addEventListener(MouseEvent.MOUSE_MOVE, onMovseMove);
		}

		public function measure():void
		{
			for (var i:int=0; i < _leftPriceLabels.length; i++)
			{
				var label:TextField=_leftPriceLabels[i] as TextField;
				label.x=0;
				if (i == 0)
					label.y=_insStartPoint.y + (i * (_insHeight / (_divideHeight * _insHeightRate))) - 5;
				else
					label.y=_insStartPoint.y + (i * (_insHeight / (_divideHeight * _insHeightRate))) - 10;
				label.width=_insStartPoint.x;
			}
			for (var i:int=0; i < _rightPercentLabels.length; i++)
			{
				var label:TextField=_rightPercentLabels[i] as TextField;
				label.x=_insStartPoint.x + _insWidth + 1;
				if (i == 0)
					label.y=_insStartPoint.y + (i * (_insHeight / (_divideHeight * _insHeightRate))) - 5;
				else
					label.y=_insStartPoint.y + (i * (_insHeight / (_divideHeight * _insHeightRate))) - 10;
				label.width=_canvas.width - _insStartPoint.x - _insWidth;
			}
			for (var i:int=0; i < _amountLabels.length; i++)
			{
				var label:TextField=_amountLabels[i] as TextField;
				label.x=0;
				label.y=_volStartPoint.y + (i * (_volHeight / (_divideHeight * (1 - _insHeightRate)))) - 8;
				label.width=_volStartPoint.x;
			}
			for (var i:int=0; i < _timeLabels.length; i++)
			{
				var label:TextField=_timeLabels[i] as TextField;
				if (i == 0)
					label.x=_insStartPoint.x - 30;
				else if (i == _timeLabels.length - 1)
					label.x=_insStartPoint.x + _insWidth;
				else
					label.x=_divideStartXPos + _divideXWidth * (i - 1) + _hourOffset;
				label.y=_volStartPoint.y + _volHeight + 1;
			}



		}

		public function paint():void
		{
			//画矩形
			paintBackground();
			if (!_data)
				return;
			calMaxSpread();
			calMaxVol();
			//画走势图
			paintInsGraph();
			//画均价
			paintAvgGraph();
			//画成交量
			paintVolGraph();
			//画左边的价格
			paintPrice();
			//画下边的量
			paintVol();
			//画右边的百分比
			paintRise();
			//画下边时间
			paintTime();
		}


		public function paintBackground():void
		{
			_canvas.graphics.lineStyle(1, 0xaaaaa2, 1);
			this._canvas.graphics.beginFill(0xffffff, 0);
			_canvas.graphics.drawRect(_insStartPoint.x, _insStartPoint.y, _insWidth, _insHeight + _volHeight);
			//等分虚线
			_canvas.graphics.lineStyle(1, 0xd3d3d3, 1);
			for (var i:int=0; i <= _divideXNum; i++)
			{
				var _pointDivideX:Number=_divideStartXPos + i * _divideXWidth;
				var _beginPoint:Point=new Point(_pointDivideX, _insStartPoint.y);
				var _endPoint:Point=new Point(_pointDivideX, _insStartPoint.y + _insHeight + _volHeight);
				GraphicsUtil.drawDashed(_canvas.graphics, _beginPoint, _endPoint, 5, 2);
			}
			for (i=1; i < _divideHeight; i++)
			{
				var _pointDivideY:Number=_insStartPoint.y + i * ((_insHeight + _volHeight) / _divideHeight);
				_beginPoint=new Point(_insStartPoint.x, _pointDivideY);
				_endPoint=new Point(_insStartPoint.x + _insWidth, _pointDivideY);
				GraphicsUtil.drawDashed(_canvas.graphics, _beginPoint, _endPoint, 5, 2);
			}
			//画昨收价线
			_canvas.graphics.lineStyle(1, 0xaaaaa2, 1);
			_canvas.graphics.moveTo(_insStartPoint.x, _insStartPoint.y + _insHeight / 2);
			_canvas.graphics.lineTo(_insStartPoint.x + _insWidth, _insStartPoint.y + _insHeight / 2);
			//画最大成交量线
			_canvas.graphics.moveTo(_volStartPoint.x, _volStartPoint.y);
			_canvas.graphics.lineTo(_volStartPoint.x + _volWidth, _volStartPoint.y);
			_canvas.graphics.endFill();
		}

		public function paintInsGraph():void
		{

			_canvas.graphics.lineStyle(0.1, 0x000000, 1);
			for (var i:int=0; i < _data.length; i++)
			{
				var _ins:Ins=_data[i] as Ins;
				var _point:Point=dataToPixel(_ins.newPrice, _ins.timestamp, 'ins');
				if (i == 0)
				{
					_canvas.graphics.moveTo(_insStartPoint.x + 1, _point.y);
				}
				_canvas.graphics.lineTo(_point.x, _point.y);
				_canvas.graphics.moveTo(_point.x, _point.y);
				_canvas.graphics.endFill();
				_ins.x=_point.x;
			}
		}

		public function paintAvgGraph():void
		{

			_canvas.graphics.lineStyle(0.1, 0xCCCC00, 1);
			for (var i:int=0; i < _data.length; i++)
			{
				var _ins:Ins=_data[i] as Ins;
				var _point:Point=dataToPixel(_ins.avePrice, _ins.timestamp, 'ins');
				if (i == 0)
				{
					_canvas.graphics.moveTo(_insStartPoint.x + 1, _point.y);
				}
				_canvas.graphics.lineTo(_point.x, _point.y);
				_canvas.graphics.moveTo(_point.x, _point.y);
				_canvas.graphics.endFill();
			}
		}

		public function paintVolGraph():void
		{
			if (_highVol == 0)
				return;
			for (var i:int=0; i < _data.length; i++)
			{
				var _ins:Ins=_data[i] as Ins;
				if (_ins.newPrice > _insInfo.ycPrice)
					_canvas.graphics.lineStyle(1, 0xab1c0e, 1);
				else if (_ins.newPrice == _insInfo.ycPrice)
					_canvas.graphics.lineStyle(1, 0xaaaaa2, 1);
				else
					_canvas.graphics.lineStyle(1, 0x2f792c, 1);
				var _point:Point=dataToPixel(_ins.allVolume, _ins.timestamp, 'amount');
				_canvas.graphics.moveTo(_point.x, _point.y);
				_canvas.graphics.lineTo(_point.x, _volStartPoint.y + _volHeight - 1);
				_canvas.graphics.endFill();
			}
		}

		public function paintPrice():void
		{
			var length:int=_leftPriceLabels.length;
			for (var i:int=0; i < length; i++)
			{
				var label:TextField=_leftPriceLabels[i] as TextField;
				var text:String=NumberFormat.dynamicPrecisionStr((_insInfo.ycPrice + _maxSpread) - (_maxSpread * 2) / (_divideHeight * _insHeightRate) * i);
				label.htmlText='<p align="right"><font face="Arial" size="10" color="' + ((i < Math.floor(length / 2)) ? "#ab1c0e" : (i == Math.floor(length / 2)) ? "#aaaaa2" : "#2f792c") + '">' + text + '</font></p>';
			}
		}


		public function paintRise():void
		{
			var length:int=_rightPercentLabels.length;
			for (var i:int=0; i < length; i++)
			{
				var label:TextField=_rightPercentLabels[i] as TextField;
				var text:String=NumberFormat.twoPrecisionStr(Math.abs(((_maxSpread) - (_maxSpread * 2) / (_divideHeight * _insHeightRate) * i) / (_insInfo.ycPrice) * 100));
				label.htmlText='<p align="left"><font face="Arial" size="10" color="' + ((i < Math.floor(length / 2)) ? "#ab1c0e" : (i == Math.floor(length / 2)) ? "#aaaaa2" : "#2f792c") + '">' + text + '%</font></p>';
			}

		}


		public function paintVol():void
		{
			var length:int=_amountLabels.length;
			for (var i:int=0; i < length; i++)
			{
				var label:TextField=_amountLabels[i] as TextField;
				var text:String=int(_highVol - _highVol / (_divideHeight * (1 - _insHeightRate)) * i) + '';
				label.htmlText='<p align="right"><font face="Arial" size="10" color="#2d5b6a">' + text + '</font></p>';
			}
		}

		public function paintTime():void
		{

		}

		public function dataToPixel(value:Number, timestamp:Date, type:String):Point
		{
			var _nowTime:Date;
			var _tmpTime:Date=new Date(1970, 1, 1, timestamp.getHours(), timestamp.getMinutes(), 0, 0);
			if(_tmpTime.time>=_startTime.time)
				_nowTime=new Date(1970, 1, 1, timestamp.getHours(), timestamp.getMinutes(), 0, 0);
			else
				_nowTime=new Date(1970, 1, 2, timestamp.getHours(), timestamp.getMinutes(), 0, 0);
			//如果当前时间大于休息时间，则当前时间减少一个小时
			if(_restHour != -1 && _nowTime.getTime()>_restTime.getTime())
				_nowTime.setTime(_nowTime.getTime() - 60*60*1000);
			var _spreadMinute:Number=(_nowTime.getTime() - _startTime.getTime()) / (1000 * 60); //相差分钟数
			var _allMinute:Number=(_endTime.getTime() - _startTime.getTime()) / (1000 * 60); //总的分钟数
			var _x:Number=_insStartPoint.x + 1 + (_spreadMinute / _allMinute * (_insWidth - 2));
			switch (type.toLowerCase())
			{
				case 'ins':
					var _y:Number=_insStartPoint.y + ((_maxSpread - (value - insInfo.ycPrice)) / (_maxSpread * 2)) * _insHeight;
					return new Point(_x, _y);
					break;
				case 'amount':
					var _y:Number=_volStartPoint.y + ((_highVol - value) / _highVol) * _volHeight;
					return new Point(_x, _y);
					break;
				default:
					return null;
					break;
			}
		}

		public function calMaxSpread():void
		{

			var _highPrice:Number=_insInfo.ycPrice;
			var _lowPrice:Number=_insInfo.ycPrice;
			for (var i:int=0; i < _data.length; i++)
			{
				var ins:Ins=_data[i] as Ins;
				if (ins.newPrice > _highPrice)
					_highPrice=ins.newPrice;
				if (ins.newPrice < _lowPrice)
					_lowPrice=ins.newPrice;
			}
			if (_highPrice == _lowPrice)
				_highPrice=_lowPrice * 1.1;
			var _spread1:Number=Math.abs(_highPrice - _insInfo.ycPrice);
			var _spread2:Number=Math.abs(_lowPrice - _insInfo.ycPrice);
			_maxSpread=_spread1 > _spread2 ? _spread1 : _spread2;
		}

		public function calMaxVol():void
		{
			_highVol=0;
			for (var i:int=0; i < _data.length; i++)
			{
				var ins:Ins=_data[i] as Ins;
				if (ins.allVolume > _highVol)
					_highVol=ins.allVolume;
			}
		}


		public function repaint():void
		{
			this._canvas.graphics.clear();
			paint();
		}

		public function get data():Array
		{
			return _data;
		}

		public function set data(value:Array):void
		{
			_data=value;
			repaint();
		}

		public function get insInfo():InsInfo
		{
			return _insInfo;
		}

		public function set insInfo(value:InsInfo):void
		{
			_insInfo=value;
		}

		public function onMovseMove(event:MouseEvent):void
		{
			if (!_data || _data.length == 0)
				return;
			var ins:Ins;
			var tmpIns:Ins;
			var width:Number=(_insWidth / ((_endTime.getTime() - _startTime.getTime()) / (1000 * 60)));
			for (var i:int=0; i < _data.length; i++)
			{
				tmpIns=_data[i] as Ins;
				if (i == 0 && _canvas.mouseX < tmpIns.x){
					ins = tmpIns;
					break;
				}
				if (_canvas.mouseX >= tmpIns.x && _canvas.mouseX <= tmpIns.x + width){
					ins = tmpIns;
					break;
				}
			}
			if(!ins) return;
			_cursor.graphics.clear();
			_cursor.graphics.lineStyle(1, 0x000000);
			//竖线
			var x:int=ins.x + 1;
			x=Math.min(x, _canvas.width);
			x=Math.max(_insStartPoint.x, x);
			
			_cursor.graphics.moveTo(x, _insStartPoint.y);
			_cursor.graphics.lineTo(x, _volStartPoint.y + _volHeight);
			//小圆圈
			var _pricePoint:Point=dataToPixel(ins.newPrice, ins.timestamp, 'ins');
			_cursor.graphics.beginFill(0xFFFDE8, 1);
			_cursor.graphics.drawCircle(x, _pricePoint.y, 1);
			_cursor.graphics.endFill();

			var _avePoint:Point=dataToPixel(ins.avePrice, ins.timestamp, 'ins');
			_cursor.graphics.beginFill(0xFFFDE8, 1);
			_cursor.graphics.drawCircle(x, _avePoint.y, 1);
			_cursor.graphics.endFill();

			var _amountPoint:Point=dataToPixel(ins.allVolume, ins.timestamp, 'amount');
			_cursor.graphics.beginFill(0xFFFDE8, 1);
			_cursor.graphics.drawCircle(x, _amountPoint.y, 1);
			_cursor.graphics.endFill();
			
			//信息框
			var htmlTxt:String = '<font color="#af8c52">時間:'+(ins.timestamp.getHours()<10?('0'+ins.timestamp.getHours()):ins.timestamp.getHours())+':'+(ins.timestamp.getMinutes()<10?('0'+ins.timestamp.getMinutes()):ins.timestamp.getMinutes())+'</font><br>';
			htmlTxt+='<font color="#af8c52">最新:</font><font color="'+getColor(ins.newPrice,_insInfo.ycPrice)+'">'+NumberFormat.dynamicPrecisionStr(ins.newPrice)+'</font><br>';
			htmlTxt+='<font color="#af8c52">均價:</font><font color="'+getColor(ins.avePrice,_insInfo.ycPrice)+'">'+NumberFormat.dynamicPrecisionStr(ins.avePrice)+'</font><br>';
			htmlTxt+='<font color="#af8c52">成交量:'+int(ins.allVolume)+'</font>';
			_insShowLabel.htmlText = htmlTxt;
			_insShowLabel.x = _canvas.mouseX + 10;
			if(_insShowLabel.x+_insShowLabel.width>_insStartPoint.x + _insWidth)
				_insShowLabel.x = _canvas.mouseX - _insShowLabel.width - 10
			_insShowLabel.y = _canvas.mouseY + 10;
			if(_insShowLabel.y+_insShowLabel.height>_insStartPoint.x + _insHeight)
				_insShowLabel.y = _canvas.mouseY - _insShowLabel.height - 10;
			if(_canvas.mouseX>=_insStartPoint.x&&_canvas.mouseX<=_insStartPoint.x + _insWidth
				&&_canvas.mouseY>=_insStartPoint.y&&_canvas.mouseY<=_insStartPoint.y + _insHeight)
				_insShowLabel.visible = true;		
			else
				_insShowLabel.visible = false;
			
			//派发当前鼠标所在的K线数据事件 
			//dispatchEvent(new DataEvent(DataEvent.CURRENT_MOUSE_POSITION_DATA, {'ins': ins}));
		}
		
		public function onMovseOut(event:MouseEvent):void{
			_cursor.graphics.clear();
			_insShowLabel.visible = false;
		}
		
		/**
		 * 根据价格与昨收价返回颜色
		 * @param price
		 * @param ycPrice
		 * @return 
		 */
		private function getColor(price:Number,ycPrice:Number):String{
			return price>ycPrice?'#c61b13':(price==ycPrice)?'#a2a091':'#2c6822'
		}


	}
}